#requires -version 2
Function Get-NaSystemAvailableReplicationTransfers {
	<#
	.Synopsis
   		Provide a mechanism to calculate the number of replication operations that could be started.
	.Description
   		Provide a mechanism to calculate the number of replication operations that could be started. 
   		Returns the number of replication operations that could be started for each replication type.
   		Another output is the maximum number of transfers for each replication type. 
	.Parameter Server
	    NaServer to query
	.Example
   		PS > Get-NaSystemAvailableReplicationTransfers
	.Outputs
    	PSObject[]
   	#>
	[CmdletBinding(SupportsShouldProcess=$FALSE,SupportsTransactions=$False,ConfirmImpact="None",DefaultParameterSetName="")]
    param (		
		[Parameter(Position=0,ValueFromPipeline=$True,HelpMessage="NaServer to query")]
		[NetApp.SDK.NaServer] 
		$server = (Get-NaServer)
    )
    Process{
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("system-available-replication-transfers")
        try {
			$result  = ([xml]$server.InvokeElem($request)).results
		}
		catch [NetApp.Manage.NaApiFailedException]{
			Write-Warning $_.Exception.GetBaseException().message
			$result = $null
			continue;
		}
		if ($?){
			write-output $result."replication-transfer-table"."replication-transfer-info" | 
			Select-Object @{
				Name='Type'
				Expression={$_."replication-type"}
			}, 
			@{
				Name='AvailableTransfers'
				Expression = { [int64]$_."replication-available-transfers"}                
			},
			@{
				Name='MaximumTransfers'
				Expression = { [int64]$_."replication-maximum-transfers"}                
			}
		}
	}
}
Function Get-NaSystemInfo {
	<#
	.Synopsis
   		Returns the appliance information which includes cpu and backplane information.
	.Description
   		Obtain appliance information which includes cpu and backplane information. The output 
   		contains the head information in a sysconfig -a command. I/O information is not included.
	.Parameter Server
	    NaServer to query
	.Example
		PS > Get-NaSystemInfo
	.Outputs
    	PSObject[]
   	#>
	[CmdletBinding(SupportsShouldProcess=$FALSE,SupportsTransactions=$False,ConfirmImpact="None",DefaultParameterSetName="")]
    param (		
		[Parameter(Position=0,ValueFromPipeline=$True,HelpMessage="NaServer to query")]
		[NetApp.SDK.NaServer] 
		$server = (Get-NaServer)
    )
    Process{
        Write-output ([xml]$server.Invoke("system-get-info")).results."system-info" | 
            Select-Object @{
		 		Name = 'BackplanePartNumber' 
				Expression = {$_."backplane-part-number"}
			},
             @{
				Name = 'BackplaneRevision' 
				Expression = {$_."backplane-revision"}
			},
            @{
				Name = 'BackplaneSerialNumber' 
				Expression = {$_."backplane-serial-number"}
			},
            @{
				Name = 'BoardSpeed' 
				Expression = {$_."board-speed"}
			},
            @{
				Name = 'BoardType' 
				Expression = {$_."board-type"}
			},
            @{
				Name = 'ControllerAddress' 
				Expression = {$_."controller-address"}
			},
            @{
				Name = 'CpuCiobRevisionId' 
				Expression = {$_."cpu-ciob-revision-id"}
			},
            @{
				Name = 'CpuFirmwareRelease' 
				Expression = {$_."cpu-firmware-release"}
			},
            @{
				Name = 'CpuMicrocodeVersion' 
				Expression = {$_."cpu-microcode-version"}
			}, 
            @{
				Name = 'CpuPartNumber' 
				Expression = {$_."cpu-part-number"}
			}, 
            @{
				Name = 'CpuProcessorId' 
				Expression = {$_."cpu-processor-id"}
			}, 
            @{
				Name = 'CpuProcessorType' 
				Expression = {$_."cpu-processor-type"}
			}, 
            @{
				Name = 'CpuRevision' 
				Expression = {$_."cpu-revision"}
			}, 
            @{
				Name = 'CpuSerialNumber' 
				Expression = {$_."cpu-serial-number"}
			}, 
            @{
				Name = 'MemorySize' 
				Expression = {$_."memory-size"}
			}, 
            @{
				Name = 'NumberOfProcessors' 
				Expression = {$_."number-of-processors"}
			}, 
            @{
				Name = 'OnTapVersion' 
				Expression = {$server.Invoke("system-get-version").getchildcontent("version")}
			}, 
            @{
				Name = 'PartnerSystemId' 
				Expression = {$_."partner-system-id"}
			}, 
            @{
				Name = 'PartnerSystemName' 
				Expression = {$_."partner-system-name"}
			}, 
            @{
				Name = 'PartnerSystemSerialNumber'
				Expression = {$_."partner-system-serial-number"}
			}, 
            @{
				Name = 'ProdType' 
				Expression = {$_."prod-type"}
			}, 
            @{
				Name = 'SupportsRaidArray' 
				Expression = {(ConvertFrom-Nabool $_."supports-raid-array")}
			}, 
            @{
				Name = 'SystemId' 
				Expression = {$_."system-id"}
			}, 
            @{
				Name = 'SystemMachineType' 
				Expression = {$_."system-machine-type"}
			}, 
            @{
				Name = 'SystemModel' 
				Expression = {$_."system-model"}
			}, 
            @{
				Name = 'SystemName' 
				Expression = {$_."system-name"}
			}, 
            @{
				Name = 'SystemRevision' 
				Expression = {$_."system-revision"}
			}, 
            @{
				Name = 'SystemSerialNumber' 
				Expression = {$_."system-serial-number"}
			}, 
            @{
				Name = 'VendorId' 
				Expression = {$_."vendor-id"}
			}, 
            @{
				Name = 'VendorInfo' 
				Expression = {
	    			([xml]$server.Invoke("system-get-vendor-info")).results | 
                    Select-Object @{
	    				Name = 'AutosupportEmail'
	    				Expression = {$_."autosupport-email"}
	    			}, 
                    @{
	    				Name = 'AutosupportUrl'
	    				Expression = {$_."autosupport-url"}
	    			}, 
                    @{
	    				Name = 'CompleteName'
	    				Expression = {$_."complete-name"}
	    			}, 
                    @{
	    				Name = 'CustomerSupportContact'
	    				Expression = {$_."customer-support-contact"}
	    			}, 
                    @{
	    				Name = 'CustomerSupportName'
	    				Expression = {$_."customer-support-name"}
	    			}, 
                    @{
	   					Name = 'InformationUrl'
	   					Expression = {$_."information-url"}
	    			}, 
                    @{
	    				Name = 'OnTapOidPrefix'
	    				Expression = {$_."ontap-oid-prefix"}
	    			}, 
                    @{
	    				Name = 'ProductUrl'
	    				Expression = {$_."product-url"}
	    			}, 
                    @{
	    				Name = 'ShortName'
	    				Expression = {$_."short-name"}
	    			}		
				}
			}
	}
}
Function Get-NaOption {
	<#
	.Synopsis
		Get a list of all options
	.Description
		Get a list of all options
	.Parameter Name
		Name of the option. If not provided return all options.
	.Parameter Server
	    NaServer to query
	.Example
		# Get all options flexcache options
		PS > Get-NaOption -Name flexcache
	.Outputs
   		PSObject[]
   	.Link 
   		Set-NaOption
   	.Notes 
	    NAME:     Get-NaOption
	    AUTHOR:   Glenn Sizemore
	    LASTEDIT: 1/3/2009 
	    #Requires -Version 2.0  
	#>
	[CmdletBinding(SupportsShouldProcess=$FALSE,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")]
    param (		
		[Parameter(Position=0,ValueFromPipelineByPropertyName=$TRUE,HelpMessage="Name of the option to get.")]
		[string] 
		$Name,
	
		[Parameter(Position=1,ValueFromPipeline=$True,HelpMessage="NaServer to query")]
		[NetApp.SDK.NaServer] 
		$server = (Get-NaServer)
    )
    process {
	    Write-Output ([xml]$server.InvokeElem("options-list-info")).results.options."option-info" | 
            Select-Object @{
    			Name = 'Name'
    			Expression = {$_.name}
    		},
            @{
    			Name = 'value'
    			Expression = {$_.value}
    		},
            @{
    			Name = 'ClusterConstraint'
    			Expression = {$_."cluster-constraint"}
    		} | Where-Object {$_.name -match $name}
	}
}
Function Set-NaOption {
	<#
	.Synopsis
		Set the value of a single option.
	.Description
		Set the value of a single option.
	.Parameter Name
	   	Name of the option. 
	.Parameter Value
	   	Value of the option. 
	.Parameter Server
    	NaServer to query
	.Example
		# Set the flexcache.enable option
 		Set-NaOption -name "flexcache.enable" -value "on"
 	.Example
		# Copy all the autosupport option settings from filer1 to filer2
		$filer1 = new-naserver filer1
	 	$filer2 = new-naserver filer2
	 	Get-NaOption -server $filer1 |?{$_.name -match "autosupport"} | Set-NaOption -server $filer2
	.Outputs
   		PSObject
   	.Link
   		Get-NaOption
   	#>
	[CmdletBinding(SupportsShouldProcess=$True,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")]
    param (		
		[Parameter(Position=0,ValueFromPipelineByPropertyName=$TRUE,Mandatory=$TRUE,HelpMessage="Name of the option to set.")]
		[string] 
		$Name,
	
		[Parameter(Position=1,ValueFromPipelineByPropertyName=$TRUE,Mandatory=$TRUE,HelpMessage="value of the option to set.")]
		[string] 
		$Value,
		
		[Parameter(Position=2,HelpMessage="NaServer to query")]
		[NetApp.SDK.NaServer] 
		$server = (Get-NaServer)
    )
    process{
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("options-set")
		$request.AddNewChild("name",$name)
		$request.AddNewChild("value",$value)
    	if ($pscmdlet.ShouldProcess($Server.Server,"Setting option $name to $value")){
			try {
				$server.InvokeElem($request)|out-null
			}
			catch [NetApp.Manage.NaApiFailedException]{
				Write-Warning $_.Exception.GetBaseException().message
				continue;
			}
			if ($?){
				return (Get-NaOption -Name $name -server $Server) 
			}
		}
	}
}

Function Get-NaDate {
	<#
	.Synopsis
		gets current date and time from filer.
	.Description
		gets current date and time from filer.
	.Parameter Server
	    NaServer to query
	.Parameter ComplianceClock  
	    clock for the compliance is returned.
	.Example
		PS > Get-NaDate
	.Outputs
   		PSObject
   	.Link
   		Set-NaDate
   		Get-NaTimeZone
   		Set-NaTimeZone
   	#>
	[CmdletBinding(
		SupportsShouldProcess=$FALSE,
	    SupportsTransactions=$False, 
	    ConfirmImpact="low",
	    DefaultParameterSetName=""
	)]
    param (	
		[Parameter(HelpMessage="the clock for the compliance is returned")]
		[switch] 
		$ComplianceClock,
	
		[Parameter(Position=0,ValueFromPipeline=$True,HelpMessage="NaServer to query")]
		[NetApp.SDK.NaServer] 
		$server = (Get-NaServer)
    )
    Process 
    {
        $request = New-Object Netapp.Manage.NaElement -ArgumentList @("clock-get-clock")
    	if ($ComplianceClock) 
        {
    		$request.AddNewChild("is-compliance-clock",$true)
    	}	
		Else 
        {
			$request.AddNewChild("is-compliance-clock",$False)
		}
        ([xml]$server.InvokeElem($request)).results | 
            Select-Object @{
    			Name = 'Server'
				Expression = {$Server.Server}
			},
            @{
				Name = 'Local'
				Expression = {(ConvertFrom-NaTime $_."local-time" -UTC)}
			},
            @{	
				Name = 'UTC'
				Expression = {ConvertFrom-NaTime $_."utc-time" -UTC}
			}
		
	}
}
Function Set-NaDate {
	<#
	.Synopsis
		Set current date and time to the specified date and time. 
	.Description
		Set current date and time to the specified date and time. 
	.Parameter Time
		Actual value of the date and time which has to be set as the current date and time on filer. 
	.Parameter Server
	    NaServer to query
	.Example
		# Set the Filers time to the clock on this pc.
		PS > Set-NaDate
	.Outputs
   		PSObject
   	.Link
   		Get-NaDate
   		Get-NaTimeZone
   		Set-NaTimeZone
   	#>
	[CmdletBinding(
		SupportsShouldProcess=$true,
	    SupportsTransactions=$False, 
	    ConfirmImpact="low",
	    DefaultParameterSetName=""
	)]
    param (	
		[Parameter(Position=0,ValueFromPipeline=$TRUE,HelpMessage="Actual value of the date and time which has to be set on the Filer")]
		[DateTime] 
		$Time = ([datetime]::now),
	
		[Parameter(Position=1,ValueFromPipeline=$True,HelpMessage="NaServer to query")]
		[NetApp.SDK.NaServer] 
		$server = (Get-NaServer)
	)
	Process
    {
	    $request = New-Object Netapp.Manage.NaElement -ArgumentList @("clock-set-clock")
		$Request.AddNewChild("time",(ConvertTo-NaTime $Time.ToUniversalTime()))
		$request.AddNewChild("is-utc-clock",$True)
        
	    if ($pscmdlet.ShouldProcess($Server.Server, "Setting system clock $($Time)")) 
        {
            Try
            {
    		    $result = ([xml]$server.InvokeElem($request)).results
                $server.InvokeElem($request) | out-null
            }
            catch [NetApp.Manage.NaApiFailedException]
            {
                write-warning $_.Exception.GetBaseException().message.replace("clock-set-clock api","Set-NaTime cmdlet").replace("Warning: ",'')
    		    return $null
            }
            Get-NaDate -Server $server
		}
	}
}
Function Get-NaTimeZone {
	<#
	.Synopsis
		Gets current timezone and timezone file version. 
	.Description
		Gets current timezone and timezone file version. 
	.Parameter Server
	    NaServer to query	   
	.Example
		PS > Get-NaTimeZone
	.Outputs
   		PSObject
   	.Link
   		Get-NaDate
   		Set-NaDate
   		Set-NaTimeZone
   	#>
	[CmdletBinding(
		SupportsShouldProcess=$FALSE,
	    SupportsTransactions=$False, 
	    ConfirmImpact="low",
	    DefaultParameterSetName=""
	)]
    param (	
		[Parameter(Position=0,ValueFromPipeline=$True,HelpMessage="NaServer to query")]
		[NetApp.SDK.NaServer] 
		$server = (Get-NaServer)
    )
    Process {
	   $request = New-Object Netapp.Manage.NaElement -ArgumentList @("clock-get-timezone")
	   write-output ([xml]$server.InvokeElem("clock-get-timezone")).results | 
       Select-Object @{
	 		Name = 'Server'
			Expression = {$Server.Server}
		},
        @{
			Name = 'TimeZone'
			Expression = {$_."timezone"}
		},
        @{	
			Name = 'UTC'
			Expression = {$_."timezone-utc"}
		},
        @{	
			Name = 'Timzone_version'
			Expression = {$_."timezone-version"}
		}
	}
}
Function Set-NaTimeZone {
	<#
	.Synopsis
		Set current timezone to the specified timezone.
	.Description
		Set current timezone to the specified timezone.
	.Parameter TimeZone
		Name of the timezone value which has to be set as current timezone value. A timezone can have 
		one of the two formats:

   		1. "Using a location string specified in Arthur David Olsen's public domain time zone database. 
   		For example, "Americas/New_York" represents most of the Eastern Time Zone.";
   		2. "A traditional time zone abbreviation incorporating default rules for daylight savings time. 
   		For example, "EST5EDT" for the US Eastern Time Zone."; 
	.Parameter Server
	    NaServer to query	   
	.Example
		PS > Set-NaTimeZone -TimeZone EST
	.Outputs
   		PSObject
   	.Link
   		Get-NaDate
   		Set-NaDate
   		Get-NaTimeZone
   	.Notes 
	    NAME:     Get-NaTimeZone
	    AUTHOR:   Glenn Sizemore
	    LASTEDIT: 1/4/2009 
	    #Requires -Version 2.0  
	#>
    [CmdletBinding(SupportsShouldProcess=$True,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")]
    param (	
    [Parameter(Position=0,ValueFromPipeline=$True,HelpMessage="Name of the timezone value which has to be set as current timezone value.")]
# #region ValidateSet
		[ValidateSet(
			'Africa/Abidjan',
			'Africa/Abidjan',
			'Africa/Accra',
			'Africa/Addis_Ababa',
			'Africa/Algiers',
			'Africa/Asmara',
			'Africa/Asmera',
			'Africa/Bamako',
			'Africa/Bangui',
			'Africa/Banjul',
			'Africa/Bissau',
			'Africa/Blantyre',
			'Africa/Brazzaville',
			'Africa/Bujumbura',
			'Africa/Cairo',
			'Africa/Casablanca',
			'Africa/Ceuta',
			'Africa/Conakry',
			'Africa/Dakar',
			'Africa/Dar_es_Salaam',
			'Africa/Djibouti',
			'Africa/Douala',
			'Africa/El_Aaiun',
			'Africa/Freetown',
			'Africa/Gaborone',
			'Africa/Harare',
			'Africa/Johannesburg',
			'Africa/Kampala',
			'Africa/Khartoum',
			'Africa/Kigali',
			'Africa/Kinshasa',
			'Africa/Lagos',
			'Africa/Libreville',
			'Africa/Lome',
			'Africa/Luanda',
			'Africa/Lubumbashi',
			'Africa/Lusaka',
			'Africa/Malabo',
			'Africa/Maputo',
			'Africa/Maseru',
			'Africa/Mbabane',
			'Africa/Mogadishu',
			'Africa/Monrovia',
			'Africa/Nairobi',
			'Africa/Ndjamena',
			'Africa/Niamey',
			'Africa/Nouakchott',
			'Africa/Ouagadougou',
			'Africa/Porto-Novo',
			'Africa/Sao_Tome',
			'Africa/Timbuktu',
			'Africa/Tripoli',
			'Africa/Tunis',
			'Africa/Windhoek',
			'America/Adak',
			'America/Anchorage',
			'America/Anguilla',
			'America/Antigua',
			'America/Araguaina',
			'America/Argentina/Buenos_Aires',
			'America/Argentina/Catamarca',
			'America/Argentina/ComodRivadavia',
			'America/Argentina/Cordoba',
			'America/Argentina/Jujuy',
			'America/Argentina/La_Rioja',
			'America/Argentina/Mendoza',
			'America/Argentina/Rio_Gallegos',
			'America/Argentina/San_Juan',
			'America/Argentina/San_Luis',
			'America/Argentina/Tucuman',
			'America/Argentina/Ushuaia',
			'America/Aruba',
			'America/Asuncion',
			'America/Atikokan',
			'America/Atka',
			'America/Bahia',
			'America/Barbados',
			'America/Belem',
			'America/Belize',
			'America/Blanc-Sablon',
			'America/Boa_Vista',
			'America/Bogota',
			'America/Boise',
			'America/Buenos_Aires',
			'America/Cambridge_Bay',
			'America/Campo_Grande',
			'America/Cancun',
			'America/Caracas',
			'America/Catamarca',
			'America/Cayenne',
			'America/Cayman',
			'America/Chicago',
			'America/Chihuahua',
			'America/Coral_Harbour',
			'America/Cordoba',
			'America/Costa_Rica',
			'America/Cuiaba',
			'America/Curacao',
			'America/Danmarkshavn',
			'America/Dawson',
			'America/Dawson_Creek',
			'America/Denver',
			'America/Detroit',
			'America/Dominica',
			'America/Edmonton',
			'America/Eirunepe',
			'America/El_Salvador',
			'America/Ensenada',
			'America/Fort_Wayne',
			'America/Fortaleza',
			'America/Glace_Bay',
			'America/Godthab',
			'America/Goose_Bay',
			'America/Grand_Turk',
			'America/Grenada',
			'America/Guadeloupe',
			'America/Guatemala',
			'America/Guayaquil',
			'America/Guyana',
			'America/Halifax',
			'America/Havana',
			'America/Hermosillo',
			'America/Indiana/Indianapolis',
			'America/Indiana/Knox',
			'America/Indiana/Marengo',
			'America/Indiana/Petersburg',
			'America/Indiana/Tell_City',
			'America/Indiana/Vevay',
			'America/Indiana/Vincennes',
			'America/Indiana/Winamac',
			'America/Indianapolis',
			'America/Inuvik',
			'America/Iqaluit',
			'America/Jamaica',
			'America/Jujuy',
			'America/Juneau',
			'America/Kentucky/Louisville',
			'America/Kentucky/Monticello',
			'America/Knox_IN',
			'America/La_Paz',
			'America/Lima',
			'America/Los_Angeles',
			'America/Louisville',
			'America/Maceio',
			'America/Managua',
			'America/Manaus',
			'America/Marigot',
			'America/Martinique',
			'America/Mazatlan',
			'America/Mendoza',
			'America/Menominee',
			'America/Merida',
			'America/Mexico_City',
			'America/Miquelon',
			'America/Moncton',
			'America/Monterrey',
			'America/Montevideo',
			'America/Montreal',
			'America/Montserrat',
			'America/Nassau',
			'America/New_York',
			'America/Nipigon',
			'America/Nome',
			'America/Noronha',
			'America/North_Dakota/Center',
			'America/North_Dakota/New_Salem',
			'America/Panama',
			'America/Pangnirtung',
			'America/Paramaribo',
			'America/Phoenix',
			'America/Port-au-Prince',
			'America/Port_of_Spain',
			'America/Porto_Acre',
			'America/Porto_Velho',
			'America/Puerto_Rico',
			'America/Rainy_River',
			'America/Rankin_Inlet',
			'America/Recife',
			'America/Regina',
			'America/Resolute',
			'America/Rio_Branco',
			'America/Rosario',
			'America/Santarem',
			'America/Santiago',
			'America/Santo_Domingo',
			'America/Sao_Paulo',
			'America/Scoresbysund',
			'America/Shiprock',
			'America/St_Barthelemy',
			'America/St_Johns',
			'America/St_Kitts',
			'America/St_Lucia',
			'America/St_Thomas',
			'America/St_Vincent',
			'America/Swift_Current',
			'America/Tegucigalpa',
			'America/Thule',
			'America/Thunder_Bay',
			'America/Tijuana',
			'America/Toronto',
			'America/Tortola',
			'America/Vancouver',
			'America/Virgin',
			'America/Whitehorse',
			'America/Winnipeg',
			'America/Yakutat',
			'America/Yellowknife',
			'Antarctica/Casey',
			'Antarctica/Davis',
			'Antarctica/DumontDUrville',
			'Antarctica/Mawson',
			'Antarctica/McMurdo',
			'Antarctica/Palmer',
			'Antarctica/Rothera',
			'Antarctica/South_Pole',
			'Antarctica/Syowa',
			'Antarctica/Vostok',
			'Arctic/Longyearbyen',
			'Asia/Aden',
			'Asia/Almaty',
			'Asia/Amman',
			'Asia/Anadyr',
			'Asia/Aqtau',
			'Asia/Aqtobe',
			'Asia/Ashgabat',
			'Asia/Ashkhabad',
			'Asia/Baghdad',
			'Asia/Bahrain',
			'Asia/Baku',
			'Asia/Bangkok',
			'Asia/Beirut',
			'Asia/Bishkek',
			'Asia/Brunei',
			'Asia/Calcutta',
			'Asia/Choibalsan',
			'Asia/Chongqing',
			'Asia/Chungking',
			'Asia/Colombo',
			'Asia/Dacca',
			'Asia/Damascus',
			'Asia/Dhaka',
			'Asia/Dili',
			'Asia/Dubai',
			'Asia/Dushanbe',
			'Asia/Gaza',
			'Asia/Harbin',
			'Asia/Ho_Chi_Minh',
			'Asia/Hong_Kong',
			'Asia/Hovd',
			'Asia/Irkutsk',
			'Asia/Istanbul',
			'Asia/Jakarta',
			'Asia/Jayapura',
			'Asia/Jerusalem',
			'Asia/Kabul',
			'Asia/Kamchatka',
			'Asia/Karachi',
			'Asia/Kashgar',
			'Asia/Katmandu',
			'Asia/Kolkata',
			'Asia/Krasnoyarsk',
			'Asia/Kuala_Lumpur',
			'Asia/Kuching',
			'Asia/Kuwait',
			'Asia/Macao',
			'Asia/Macau',
			'Asia/Magadan',
			'Asia/Makassar',
			'Asia/Manila',
			'Asia/Muscat',
			'Asia/Nicosia',
			'Asia/Novosibirsk',
			'Asia/Omsk',
			'Asia/Oral',
			'Asia/Phnom_Penh',
			'Asia/Pontianak',
			'Asia/Pyongyang',
			'Asia/Qatar',
			'Asia/Qyzylorda',
			'Asia/Rangoon',
			'Asia/Riyadh',
			'Asia/Saigon',
			'Asia/Sakhalin',
			'Asia/Samarkand',
			'Asia/Seoul',
			'Asia/Shanghai',
			'Asia/Singapore',
			'Asia/Taipei',
			'Asia/Tashkent',
			'Asia/Tbilisi',
			'Asia/Tehran',
			'Asia/Tel_Aviv',
			'Asia/Thimbu',
			'Asia/Thimphu',
			'Asia/Tokyo',
			'Asia/Ujung_Pandang',
			'Asia/Ulaanbaatar',
			'Asia/Ulan_Bator',
			'Asia/Urumqi',
			'Asia/Vientiane',
			'Asia/Vladivostok',
			'Asia/Yakutsk',
			'Asia/Yekaterinburg',
			'Asia/Yerevan',
			'Atlantic/Azores',
			'Atlantic/Bermuda',
			'Atlantic/Canary',
			'Atlantic/Cape_Verde',
			'Atlantic/Faeroe',
			'Atlantic/Faroe',
			'Atlantic/Jan_Mayen',
			'Atlantic/Madeira',
			'Atlantic/Reykjavik',
			'Atlantic/South_Georgia',
			'Atlantic/St_Helena',
			'Atlantic/Stanley',
			'Australia/ACT',
			'Australia/Adelaide',
			'Australia/Brisbane',
			'Australia/Broken_Hill',
			'Australia/Canberra',
			'Australia/Currie',
			'Australia/Darwin',
			'Australia/Eucla',
			'Australia/Hobart',
			'Australia/LHI',
			'Australia/Lindeman',
			'Australia/Lord_Howe',
			'Australia/Melbourne',
			'Australia/NSW',
			'Australia/North',
			'Australia/Perth',
			'Australia/Queensland',
			'Australia/South',
			'Australia/Sydney',
			'Australia/Tasmania',
			'Australia/Victoria',
			'Australia/West',
			'Australia/Yancowinna',
			'Brazil/Acre',
			'Brazil/DeNoronha',
			'Brazil/East',
			'Brazil/West',
			'CET',
			'CST6CDT',
			'Canada/Atlantic',
			'Canada/Central',
			'Canada/East-Saskatchewan',
			'Canada/Eastern',
			'Canada/Mountain',
			'Canada/Newfoundland',
			'Canada/Pacific',
			'Canada/Saskatchewan',
			'Canada/Yukon',
			'Chile/Continental',
			'Chile/EasterIsland',
			'Cuba',
			'EET',
			'EST5EDT',
			'Egypt',
			'Eire',
			'Etc/GMT',
			'Etc/GMT+0',
			'Etc/GMT+1',
			'Etc/GMT+10',
			'Etc/GMT+11',
			'Etc/GMT+12',
			'Etc/GMT+2',
			'Etc/GMT+3',
			'Etc/GMT+4',
			'Etc/GMT+5',
			'Etc/GMT+6',
			'Etc/GMT+7',
			'Etc/GMT+8',
			'Etc/GMT+9',
			'Etc/GMT-0',
			'Etc/GMT-1',
			'Etc/GMT-10',
			'Etc/GMT-11',
			'Etc/GMT-12',
			'Etc/GMT-13',
			'Etc/GMT-14',
			'Etc/GMT-2',
			'Etc/GMT-3',
			'Etc/GMT-4',
			'Etc/GMT-5',
			'Etc/GMT-6',
			'Etc/GMT-7',
			'Etc/GMT-8',
			'Etc/GMT-9',
			'Etc/GMT0',
			'Etc/Greenwich',
			'Etc/UCT',
			'Etc/UTC',
			'Etc/Universal',
			'Etc/Zulu',
			'Europe/Amsterdam',
			'Europe/Andorra',
			'Europe/Athens',
			'Europe/Belfast',
			'Europe/Belgrade',
			'Europe/Berlin',
			'Europe/Bratislava',
			'Europe/Brussels',
			'Europe/Bucharest',
			'Europe/Budapest',
			'Europe/Chisinau',
			'Europe/Copenhagen',
			'Europe/Dublin',
			'Europe/Gibraltar',
			'Europe/Guernsey',
			'Europe/Helsinki',
			'Europe/Isle_of_Man',
			'Europe/Istanbul',
			'Europe/Jersey',
			'Europe/Kaliningrad',
			'Europe/Kiev',
			'Europe/Lisbon',
			'Europe/Ljubljana',
			'Europe/London',
			'Europe/Luxembourg',
			'Europe/Madrid',
			'Europe/Malta',
			'Europe/Mariehamn',
			'Europe/Minsk',
			'Europe/Monaco',
			'Europe/Moscow',
			'Europe/Nicosia',
			'Europe/Oslo',
			'Europe/Paris',
			'Europe/Podgorica',
			'Europe/Prague',
			'Europe/Riga',
			'Europe/Rome',
			'Europe/Samara',
			'Europe/San_Marino',
			'Europe/Sarajevo',
			'Europe/Simferopol',
			'Europe/Skopje',
			'Europe/Sofia',
			'Europe/Stockholm',
			'Europe/Tallinn',
			'Europe/Tirane',
			'Europe/Tiraspol',
			'Europe/Uzhgorod',
			'Europe/Vaduz',
			'Europe/Vatican',
			'Europe/Vienna',
			'Europe/Vilnius',
			'Europe/Volgograd',
			'Europe/Warsaw',
			'Europe/Zagreb',
			'Europe/Zaporozhye',
			'Europe/Zurich',
			'Factory',
			'GB',
			'GB-Eire',
			'GMT',
			'GMT+0',
			'GMT-0',
			'GMT0',
			'Greenwich',
			'HST',
			'Hongkong',
			'Iceland',
			'Indian/Antananarivo',
			'Indian/Chagos',
			'Indian/Christmas',
			'Indian/Cocos',
			'Indian/Comoro',
			'Indian/Kerguelen',
			'Indian/Mahe',
			'Indian/Maldives',
			'Indian/Mauritius',
			'Indian/Mayotte',
			'Indian/Reunion',
			'Iran',
			'Israel',
			'Jamaica',
			'Japan',
			'Kwajalein',
			'Libya',
			'MET',
			'MST',
			'MST7MDT',
			'Mexico/BajaNorte',
			'Mexico/BajaSur',
			'Mexico/General',
			'NZ',
			'NZ-CHAT',
			'Navajo',
			'PRC',
			'PST8PDT',
			'Pacific/Apia',
			'Pacific/Auckland',
			'Pacific/Chatham',
			'Pacific/Easter',
			'Pacific/Efate',
			'Pacific/Enderbury',
			'Pacific/Fakaofo',
			'Pacific/Fiji',
			'Pacific/Funafuti',
			'Pacific/Galapagos',
			'Pacific/Gambier',
			'Pacific/Guadalcanal',
			'Pacific/Guam',
			'Pacific/Honolulu',
			'Pacific/Johnston',
			'Pacific/Kiritimati',
			'Pacific/Kosrae',
			'Pacific/Kwajalein',
			'Pacific/Majuro',
			'Pacific/Marquesas',
			'Pacific/Midway',
			'Pacific/Nauru',
			'Pacific/Niue',
			'Pacific/Norfolk',
			'Pacific/Noumea',
			'Pacific/Pago_Pago',
			'Pacific/Palau',
			'Pacific/Pitcairn',
			'Pacific/Ponape',
			'Pacific/Port_Moresby',
			'Pacific/Rarotonga',
			'Pacific/Saipan',
			'Pacific/Samoa',
			'Pacific/Tahiti',
			'Pacific/Tarawa',
			'Pacific/Tongatapu',
			'Pacific/Truk',
			'Pacific/Wake',
			'Pacific/Wallis',
			'Pacific/Yap',
			'Poland',
			'Portugal',
			'ROC',
			'ROK',
			'Singapore',
			'Turkey',
			'UCT',
			'US/Alaska',
			'US/Aleutian',
			'US/Arizona',
			'US/Central',
			'US/East-Indiana',
			'US/Eastern',
			'US/Hawaii',
			'US/Indiana-Starke',
			'US/Michigan',
			'US/Mountain',
			'US/Pacific',
			'US/Pacific-New',
			'US/Samoa',
			'UTC',
			'Universal',
			'W-SU',
			'WET',
			'Zulu',
			'EST'
		)]
# #endregion
		[string] 
		$TimeZone,
		
		[Parameter(Position=1,ValueFromPipeline=$True,HelpMessage="NaServer to query")]
		[NetApp.SDK.NaServer] 
		$server = (Get-NaServer)
    )
    Process {
		$request = New-Object Netapp.Manage.NaElement -ArgumentList @("clock-set-timezone")
		$request.AddNewChild("timezone",$TimeZone)
		if ($pscmdlet.ShouldProcess($Server.Server, "Setting TimeZone to $($TimeZone)")) {
			try {
				$server.InvokeElem($request)|out-null
			}
			catch [NetApp.Manage.NaApiFailedException]{
				Write-Warning $_.Exception.GetBaseException().message
				continue;
			}
			if ($?){
				return Get-NaTimeZone -Server $Server
			}
		}
	}
}
Function Ping-NaHost {
	<#
	.Synopsis
		Ping a host from the filer. 
	.Description
		Ping a host. The cmdlet pings the host count times, and returns the number of
		successful pings and times. 
		 
		EHOSTNOTFOUND is returned if the host cannot be resolved. 
		EHOSTNOCONTACT is returned if the host cannot be pinged. 
		 
		The interval between ping attempts is 1 second. IPv6 is not supported at 
		this time.
	.Parameter Name
	    The name or the IP address of the host to ping. The format is an IPv4 host 
	    name or an IP address. 
	.Parameter Count
		The number of pings. Default is 3. Range: [1..16] 
	.Parameter Quiet
		Returns no data, intead the cmdlet will hold control  first successful 
		ping of retry-count attempts
	.Parameter Server
	    NaServer to query	   
	.Example
		PS > Get-NaPing 192.168.1.1
	.Outputs
   		PSObject
   	.Link
   		Resolve-NaHost
   	#>
	[CmdletBinding(SupportsShouldProcess=$FALSE,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")]
    param (	
		[Parameter(Position=0,ValueFromPipelineByPropertyName=$TRUE,Mandatory=$TRUE,HelpMessage="The name or the IP address of the host to ping.")]
		[string] 
		$Name,
		
		[Parameter(Position=1,HelpMessage="The number of pings. Default is 3.")]
		[ValidateRange(1,16)]
		[int] 
		$Count=3,
		
		[Parameter()]
		[switch]
		$Quiet,
		
		[Parameter(Position=2,HelpMessage="NaServer to query")]
		[NetApp.SDK.NaServer] 
		$server = (Get-NaServer)
    )
    Process{
	    if ($quiet) {
	        $request = New-Object Netapp.Manage.NaElement -ArgumentList @("net-ping")
	        $request.AddNewChild("host-name-or-ip-address", $Name)
	        if ($Count -gt 5) {$count = 5}
	        $request.AddNewChild("retry-count",$Count)
	        Try{
                $server.InvokeElem($request)|out-null
            }
            catch [NetApp.Manage.NaApiFailedException]{
                Write-Warning $_.Exception.GetBaseException().message
                return $null
            }
        } 
	    else{
	       	$request = New-Object Netapp.Manage.NaElement -ArgumentList @("net-ping-info")
	       	$request.AddNewChild("host-name-or-ip-address", $Name)
	       	$request.AddNewChild("ping-count",$Count)
	 		Try{
               	$result = ([xml]$server.InvokeElem($request)).results
            }
            catch [NetApp.Manage.NaApiFailedException]{
                Write-Warning $_.Exception.GetBaseException().message
                return $null
            }
		 	write-output $result | Select-Object @{
		 		Name = 'Received'
				Expression = {$_."packets-received"}
			},
            @{
				Name = 'Transmitted'
				Expression = {$_."packets-transmitted"}
			},
            @{	
				Name = 'RoundTripMaximumTime'
				Expression = {$_."round-trip-maximum-time"}
			},
            @{	
				Name = 'RoundTripMeanTime'
				Expression = {$_."round-trip-mean-time"}
			}
            ,@{	
				Name = 'RoundTripMinimumTime'
				Expression = {$_."round-trip-minimum-time"}
			}
	    }
	}
}
Function Resolve-NaHost {
	<#
	.Synopsis
		Resolves a host name to one or more IP addresses.
	.Description
		Resolves a host name to one or more IP addresses.
		EHOSTNOTFOUND if the host name cannot be resolved. 
		Does not support IPv6 at this time.
		this time.
	.Parameter Name
	    Name of the host to resolved. 
	.Parameter Server
	    NaServer to query	   
	.Example
		PS > Resolve-NaPing Toaster.get-admin.com
	.Outputs
   		PSObject
   	.Link
   		Ping-NaHost
   	#>
	[CmdletBinding(SupportsShouldProcess=$FALSE,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")]
    param (	
		[Parameter(Position=0,ValueFromPipelineByPropertyName=$TRUE,Mandatory=$TRUE,HelpMessage="Name of the host to resolved.")]
		[string] 
		$Name,
		
		[Parameter(Position=1,HelpMessage="NaServer to query")]
		[NetApp.SDK.NaServer] 
		$server = (Get-NaServer)
    )
    Process{
    	$request = New-Object Netapp.Manage.NaElement -ArgumentList @("net-resolve")
    	$request.AddNewChild("host-name", $Name)
	    Try{
            $result = ([xml]$server.InvokeElem($request)).results
        }
        catch [NetApp.Manage.NaApiFailedException]{
            Write-Warning $_.Exception.GetBaseException().message
            return $null
        }
    	$result."ip-addresses"| % {
    		write-output $_."ip-address"
    	}
	}
}
function Invoke-NaExpression {
	<#
	.Synopsis
	   Runs commands or expressions on the target server
	.Description
	   Runs commands or expressions on the target server.
	.Parameter Command
	    Command to be executed
	.Parameter Server
	    NaServer to query	   
	.Example
		PS > Invoke-NaExpression -command 'ifconfig -a'
	.Outputs
   		PSObject
   	#>
	[CmdletBinding(SupportsShouldProcess=$True,SupportsTransactions=$False,ConfirmImpact="low",DefaultParameterSetName="")]
    param (	
		[Parameter(Position=0,Mandatory=$TRUE,HelpMessage="Command to be ran.")]
		[string] 
		$Command,
		
		[Parameter(Position=1,HelpMessage="NaServer to query")]
		[NetApp.SDK.NaServer] 
		$server = (Get-NaServer)
    )
    Process {  	
        $NaElement = New-Object NetApp.Manage.NaElement("system-cli")
        $arg = New-Object NetApp.Manage.NaElement("args")
        $Command -split " " | ?{$_} |%{
            $arg.AddNewChild('arg',$_)
        }
        $NaElement.AddChildElement($arg)
        $CifsString = $Server.InvokeElem($naelement).GetChildContent("cli-output")
	    if ($pscmdlet.ShouldProcess($Server.Server, "Executing $($Command)")) {
            Try{
                $result = $Server.InvokeElem($naelement).GetChildContent("cli-output")
            }
            catch [NetApp.Manage.NaApiFailedException]{
                Write-Warning $_.Exception.GetBaseException().message
                return $null
            }
        	if ($?){
                return $result
            }
        }
	}
}